//
//  TTTViewController.m
//  pres
//
//  Created by xingshuai on 2021/1/8.
//

#import "TTTViewController.h"

#import <Masonry.h>

@interface TTTViewController () <UIViewControllerTransitioningDelegate>

@end

@implementation TTTViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = UIColor.redColor;
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (XSLTransitionAnimation *)transitionAnimation {
    if (_transitionAnimation == nil) {
        _transitionAnimation = [[XSLTransitionAnimation alloc] init];
        self.transitioningDelegate = self;
    }
    return _transitionAnimation;
}

#pragma mark -- UIViewControllerTransitioningDelegate
//返回一个处理present动画过渡的对象
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    self.transitionAnimation.transitionType = XSLTransitionTypePresent;
    return self.transitionAnimation;
}
//返回一个处理dismiss动画过渡的对象
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    //这里我们初始化dismissType
    self.transitionAnimation.transitionType = XSLTransitionTypeDissmiss;
    return self.transitionAnimation;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
